package com.hntest.service.impl;

import com.hntest.dao.UserFileDao;
import com.hntest.entity.Pager;
import com.hntest.entity.RealAuth;
import com.hntest.entity.UserFile;
import com.hntest.service.UserFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("UserFileService")
public class UserFileServiceImpl  implements UserFileService {

    @Autowired
    private UserFileDao userFileDao;

    @Override
    public int insertUserFile(UserFile userFile) {
        return userFileDao.insertUserFile(userFile);
    }

    @Override
    public List<UserFile> getListByPage(Pager pager, UserFile userFile) {
        pager.setTotalCounts(userFileDao.getCounts(userFile));
        Map<String, Object> map=new HashMap<>();
        map.put("userFile", userFile);
        map.put("pageStart", (pager.getCurrPage()-1)*pager.getPageSize()+1);
        map.put("pageEnd",pager.getCurrPage()*pager.getPageSize());
        //将map中带回的数据保存到list集合中返回
        List<UserFile> list=userFileDao.getListByPage(map);
        return list;
    }

    @Override
    public int updateUserFile(UserFile userFile) {
        return userFileDao.updateUserFile(userFile);
    }

    @Override
    public List<UserFile> selectById(int id ,boolean fileTypeId) {
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("fileTypeId",fileTypeId);
        List<UserFile> list = userFileDao.selectById(map);
        return list;
    }

    @Override
    public UserFile selectById2(int id) {
        return userFileDao.selectById2(id);
    }

    @Override
    public int getScore(int lid) {
        return userFileDao.getScore(lid);
    }

}
